﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HBKY.Shop.Common.Attributes
{
    /// <summary>
    /// 标记这个特性的方法，它的执行结果将会存入Redis缓存中
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, Inherited = true)]
    public class CachingAttribute : System.Attribute
    {
        /// <summary>
        /// 缓存过期时间累加值（单位：分钟）
        /// 当前时间+缓存过期累加值=过期时间
        /// </summary>
        public int AbsoluteExpiration { get; set; } = 60;

        public string CachKey { get; set; }
       
        public bool IsCarryParam { get; set; }

        public CachingAttribute(string cachKey,bool isCarryParam = false)
        {
            CachKey = cachKey;
            IsCarryParam = isCarryParam;
        }

        public CachingAttribute(string cachKey,int time, bool isCarryParam = false)
        {
            CachKey = cachKey;
            AbsoluteExpiration = time;
            IsCarryParam = isCarryParam;
        }
    }
}
